package com.CityHunter.Activity;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.CityHunter.R;
import com.CityHunter.Handler.Http_Handler;
import com.CityHunter.R.id;
import com.CityHunter.R.layout;

public class FriendListView extends Activity {
	ListView listView;
	
	private String grouptitle;
	private Http_Handler http;
	private SharedPreferences sp;
	private ArrayList<HashMap<String, Object>> friends = new ArrayList<HashMap<String, Object>>();
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.groupview);
		
		sp = getSharedPreferences("cityhunter", 0);
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			grouptitle = extras.getString("grouptitle");
			setTitle(grouptitle);
		}

	
		http = new Http_Handler();

		try {
			friends = http.getGFriendsByGroup(grouptitle,sp.getString("name", ""));
		} catch (Exception e) {
			Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
		}

		SimpleAdapter saImageItems = new SimpleAdapter(this, friends,
				R.layout.groupview_item, new String[] { "name", "status" },
				new int[] { R.id.name, R.id.status });

		listView = ((ListView) findViewById(R.id.group));
		listView.setAdapter(saImageItems);

		
	/*

		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent intent=new Intent(FriendListView.this,CityHunter.class);
				intent.putExtra("grouptitle", ppl[arg2]);
				startActivityForResult(intent,1);   

			}
		});  */
	}
}